package com.jlxy.chen.eroad;

import android.app.Activity;


import android.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.util.ArrayList;

public class OrderActivity extends Activity implements AdapterView.OnItemClickListener{

    private DrawerLayout mDrawerLayout;
    private ListView mDrawerList;
    private String[] arr1={"个人信息","接收订单","未完成订单","已完成订单"};
    private ArrayAdapter<String> adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order);
        mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
        mDrawerList = (ListView)findViewById(R.id.left_drawer);

        adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1,arr1);
        mDrawerList.setAdapter(adapter);
        mDrawerList.setOnItemClickListener(this);

    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        //动态插入Fragment到FragmentLayout中
        Fragment contentFragment = new ContentFragment();
        Bundle args = new Bundle();
        args.putString("text",arr1[position]);
        contentFragment.setArguments(args);

        android.app.FragmentManager fm = getFragmentManager();
        fm.beginTransaction().replace(R.id.content_frame,contentFragment).commit();

        mDrawerLayout.closeDrawer(mDrawerList);
    }
}
